package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.domain.StrategyCatalog;
import cn.wolfcode.wolf2w.domain.Travel;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("destinations")
public class DestinationController {

    @Autowired
    private IRegionService regionService;

    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private ITravelService travelService;

    @GetMapping("/hotRegion")
    private Object hotRegion() {
        return JsonResult.success(regionService.queryHotRegion());
    }

    @GetMapping("/search")
    private Object search(String regionId) {
        return JsonResult.success(destinationService.queryDestByRegionIdForApi(regionId));
    }

    @GetMapping("/toasts")
    private Object toasts(String destId) {
        return JsonResult.success(destinationService.queryToasts(destId));
    }

    @GetMapping("/catalogs")
    private Object catalogs(String destId) {
        List<StrategyCatalog> list = strategyCatalogService.queryCatalogByDestId(destId);
        return JsonResult.success(list);
    }

    /**
     * 点击量前3的攻略文章
     * @param destId
     * @return
     */
    @GetMapping("/strategies/viewnumTop3")
    private Object strategiesViewNumTop3(String destId) {
        List<Strategy> list = strategyService.queryViewNumTop3(destId);
        return JsonResult.success(list);
    }
    /**
     * 点击量前3的游记
     * @param destId
     * @return
     */
    @GetMapping("/travels/viewnumTop3")
    private Object travelsViewNumTop3(String destId) {
        List<Travel> list = travelService.queryViewNumTop3(destId);
        return JsonResult.success(list);
    }
}
